import Vue from "vue";
import VueRouter from "vue-router";
import HomeView from "../views/home/HomeView.vue";
import ShopView from "../views/shop/ShopView.vue";
import LiveView from "../views/live/LiveView.vue";
import MyView from "../views/my/MyView.vue";
import CollectView from "../views/collect/CollectView.vue";
import AppView from "../views/home/AppView.vue";
import TypeView from "../views/type/TypeView.vue"
import SearchPage from "../views/search/SearchPage.vue"
import SearchResult from "../views/search/SearchResult.vue" 
import VideoView from '../views/VideoFrequency/VideoView.vue'
import AttentionVIew from "../views/attention/AttentionVIew.vue";
import ChatPage from '../views/chatPage/ChatPage.vue';
import ChatDetailed from '../views/chatPage/ChatDetailed.vue'
import ShoppingCarView from "../views/shoppingCar/ShoppingCarView.vue";
import OrderView from "../views/order/OrderView.vue";
import AnchorView from "../views/anchor/AnchorView.vue";

Vue.use(VueRouter);

const routes = [
	{
		path: "/",
		name: "app",
		component: AppView,
		children: [
			{
				path: "",
				name: "home",
				component: HomeView,
			},
			{
				path: "shop",
				name: "shop",
				component: ShopView,
			},
			{
				path: "live",
				name: "live",
				component: LiveView,
			},
			{
				path: "my",
				name: "my",
				component: MyView,
			},
		],
	},
	{
		//登录
		path: "/login",
		name: "login",
		component: () => import("../views/login/LoginView.vue"),
	},
	{
		//其他登录
		path: "/otherLogin",
		name: "otherLogin",
		component: () => import("../views/login/OtherLoginView.vue"),
	},
	{
		//注册
		path: "/register",
		name: "register",
		component: () => import("../views/login/RegisterView.vue"),
	},
	{
		//收藏
		path: "/collect",
		name: "collect",
		component: CollectView,
	},
	{
		//关注
		path: "/attention",
		name: "attention",
		component: AttentionVIew,
	},
	{
		//购物车
		path: "/shoppingCar",
		name: "shoppingCar",
		component: ShoppingCarView,
	},
	{
		path: "/goods-detail/:id",
		name: "goods-detail",
		component: () => import("../views/detail/GoodsDetail.vue"),
	},
	{
		path:"/TypeView",
		name:"TypeView",
		component: TypeView,
	},
	{
		path:'/SearchPage',
		name:'SearchPage',
		component: SearchPage
	},
	{
		path:'/SearchResult',
		name:'SearchResult',
		component: SearchResult
	},
	{
		path:'/VideoView',
		name:'VideoView',
		component: VideoView
	},

		//分类
	{
		path: "/type",
		name: "TypeView",
		component: TypeView,
	},
	{
		//搜索首页
		path: "/SearchPage",
		name: "SearchPage",
		component: SearchPage,
	},
	{
		//搜索结果页
		path: "/SearchResult",
		name: "SearchResult",
		component: SearchResult,
	},
	{
		//订单
		path: "/order",
		name: "order",
		component: OrderView,
	},
	{
		//订单详情页
		path: "/order-detail/:id",
		name: "order-detail",
		component: () => import("../views/detail/OrderDetail.vue"),
	},
	{
		//聊天页
		path:'/ChatPage',
		name:'ChatPage',
		component: ChatPage
	},
	{
		//主播
		path:'/anchor',
		name:'anchor',
		component: AnchorView
	},
	{
		//聊天详情页
		path:'/ChatDetailed',
		name:'ChatDetailed',
		component: ChatDetailed
	}
];

const router = new VueRouter({
	mode: "history",
	base: process.env.BASE_URL,
	routes,
});

export default router;
const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location, onResolve, onReject) {
	if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject);
	return originalPush.call(this, location).catch((err) => err);
};
